﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改密码--layui后台管理模板</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="~/layui/css/layui.css" media="all" />
</head>
<body>
    <div class="" style="padding-left:20px;">
        <fieldset class="layui-elem-field layui-field-title"  >
            <legend>站点新增</legend>
        </fieldset>
        <form class="layui-form layui-form-pane">
            <div class="layui-form-item">
                <label class="layui-form-label">站点名称</label>
                <div class="layui-input-block">
                    <input type="text" value="" name="siteName" lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">站点编号</label>
                    <div class="layui-input-inline">
                        <input type="text" value="" name="siteNo" lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">公司名称</label>
                    <div class="layui-input-inline">
                        <input type="text" value="" name="company" lay-verify="required" class="layui-input">
                    </div>

                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">经度</label>
                    <div class="layui-input-inline">
                        <input type="text" value="" name="longAdd" lay-verify="required|number" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">纬度</label>
                    <div class="layui-input-inline">
                        <input type="text" value="" name="latAdd" lay-verify="required" class="layui-input">
                    </div>

                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">站点地址</label>
                <div class="layui-input-block">
                    <input type="text" value="" name="address" lay-verify="required" class="layui-input pwd">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">站点类别</label>
                <div class="layui-input-block">
                    @Html.B_DropDownList("站点类别", "moniType")
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">附件</label>
                <div class="layui-input-inline">
                    <input type="text" id="filePath" name="filePath" autocomplete="off" disabled="disabled" class="layui-input" />
                </div>
                <div class="layui-input-inline">
                    <button type="button" class="layui-btn" function="upload" fileElem="#filePath" fileAccept="file" fileExts="" fileSize="1024" inputs="type:test">上传图片</button>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="formData">保存</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>



        </form>
    </div>
    
    <script type="text/javascript" src="~/layui/layui.js"></script>
    <script type="text/javascript" src="~/js/formRender.js"></script>
    <script>       
        var appUrl = '@Url.Action("")';
        var id = '@Request["id"]';
        layui.use(['form','laydate','jquery'], function () {
            var form = layui.form,
                laydate = layui.laydate;
            var $ = layui.$;

            laydate.render({
                elem: '#date'
            });
            laydate.render({
                elem: '#date2',
                type:'year'
            });
            laydate.render({
                elem: '#date3',
                type: 'month'
            });
            laydate.render({
                elem: '#date4',
                type: 'time'
            });
            laydate.render({
                elem: '#date5',
                type: 'datetime'
            });
            //日期范围选择
            laydate.render({
                elem: '#date6'
                , range: true 
            });
            //监听提交
            form.on('submit(formData)', function (data) {
                if (id) {
                    data.field.id = id;
                }
                $.ajax({
                    url: '@Url.Action("Save")',
                    data: fixData(data.field),
                    success: function (res) {

                        layer.msg('保存成功！');
                    }
                })
                return false;
            });

            if ('@ViewBag.Mode' == 'edit') {
                $.ajax({
                    url: appUrl + '/getData',
                    data: {
                        id: id
                    },
                    success: function (res) {
                        var data = JSON.parse(res);
                        for (var item in data) {
                            var obj = $('[name=' + item + ']');                            
                            if (obj.length) {
                                if (obj[0].tagName == "INPUT") {
                                    obj.val(data[item]);
                                } else if (obj[0].tagName == "SELECT") {
                                    console.log($("#" + item + " option[value=" + data[item] + "]"))
                                    $("#" + item + " option[value=" + data[item]+"]").attr("selected", "selected");
                                }                                
                            }
                        }
                        form.render('select');
                    }

                });
                
            }
        })
    </script>
</body>
</html>